package com.luych.toolbox.data.service.dao;

import com.luych.toolbox.common.enums.DataBackupHistoryStatus;
import com.luych.toolbox.data.service.entity.DataBackupHistory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.Date;
import java.util.List;
import java.util.Optional;

public interface DataBackupHistoryDao extends JpaRepository<DataBackupHistory, String>, JpaSpecificationExecutor<DataBackupHistory> {

    Page<DataBackupHistory> findByNameLike(String name, Pageable pageable);

    Page<DataBackupHistory> findByDataSourceId(String dataSourceId, Pageable pageable);

    List<DataBackupHistory> findByDataSourceId(String dataSourceId);

    List<DataBackupHistory> findByStatusIn(List<DataBackupHistoryStatus> status);

    Optional<DataBackupHistory> findByDataAgentIdAndFile(String dataAgentId, String file);

    int countByDataSourceId(String dataSourceId);

    int countByDataAgentId(String dataAgentId);

    int countByDataBackupPlanId(String dataBackupPlanId);

    long countByStartDateBetween(Date start, Date end);

}